"""登录页面类"""
from selenium.webdriver.common.by import By
from page.base_page import BasePage

class LoginPage(BasePage):
    url="/crm5/"
    #定位器
    username_locator =  (By.CSS_SELECTOR,
                          "body > div.container > div > div.span4 > div > form > fieldset > input:nth-child(3)")
    password_locator = (By.CSS_SELECTOR,
                        "body > div.container > div > div.span4 > div > form > fieldset > input:nth-child(5)")
    btn_locator = (By.CSS_SELECTOR,
                                 "body > div.container > div > div.span4 > div > form > fieldset > input.btn.btn-primary")
    def input_username(self, username):
        """输入登录名"""
        self.driver.find_element(*self.username_locator).send_keys(username)
    def input_password(self, password):
        """输入密码"""
        self.driver.find_element(*self.password_locator).send_keys(password)
    def click_btn(self):
        """点击登录"""
        self.driver.find_element(*self.btn_locator).click()
    def open(self):
        """打开网页"""
        self.driver.get(self.url)
    def current_url(self):
        """返回登录厚的地址"""
        return self.driver.current_url
    def close(self):
        """关闭页面"""
        self.driver.close()

